//
//  MYGChooseListViewCell.swift
//  MYGrow
//
//  Created by 林矗 on 2024/3/17.
//

import UIKit

class MYGChooseListViewCell: UITableViewCell {
    // MARK: - Property
    var title: String = "" {
        didSet {
            titleLabel.text = title
        }
    }
    
    var subtitle: String = "" {
        didSet {
            subtitleLabel.text = subtitle
        }
    }
    
    // MARK: - init
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        selectionStyle = .none
        contentView.backgroundColor = .white
        configUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    // MARK: - UI
    private func configUI() {
        contentView.addSubview(stackView)
        contentView.addSubview(sperator)
        stackView.snp.makeConstraints { make in
            make.left.right.equalToSuperview().inset(26)
            make.top.bottom.equalToSuperview().inset(10)
        }
        
        sperator.snp.makeConstraints { make in
            make.bottom.equalToSuperview()
            make.left.right.equalToSuperview().inset(26)
            make.height.equalTo(0.5)
        }
        
        stackView.addArrangedSubviews([
            titleLabel,
            subtitleLabel
        ])
    }
    
    
    // MARK: - lazy load
    
    private lazy var stackView: UIStackView = {
        let stack = UIStackView()
        stack.axis = .vertical
        stack.spacing = 2.5
        stack.distribution = .fillProportionally
        stack.alignment = .leading
        return stack
    }()
    
    private lazy var titleLabel: UILabel = {
        let label = UILabel()
        label.font = .medium(16)
        label.textColor = .rgba(51, 51, 51)
        return label
    }()
    
    private lazy var subtitleLabel: UILabel = {
        let label = UILabel()
        label.font = .regular(14)
        label.textColor = .rgba(51, 51, 51)
        return label
    }()
    
    private lazy var icon: UIImageView = {
        let imageView = UIImageView(image: UIImage(named: ""))
        return imageView
    }()
    
    private lazy var sperator: UIView = {
        let view = UIView()
        view.backgroundColor = .rgba(238, 238, 238)
        return view
    }()
}
